﻿@{
    ViewBag.Title = "Reacord";
    Layout = "~/Views/Shared/_Layout.cshtml";
}

@using Common.BaseLibrary.Authorization
@using DepartmentWork.Model
@model DepartmentWork.Model.ProjectManintenanceRecordViewModel

<link href="~/Assets/plugins/bootstrap-select/bootstrap-select.min.css" rel="stylesheet" />
<script src="~/Assets/plugins/bootstrap-select/bootstrap-select.min.js"></script>
<link href="~/Assets/plugins/bootstrap-datepicker/css/datepicker3.css" rel="stylesheet" />
<link href="~/Assets/plugins/bootstrap-datepicker/css/datepicker-theme.css" rel="stylesheet" />
<script src="~/Assets/plugins/bootstrap-datepicker/js/bootstrap-datepicker.js"></script>
<script src="~/Assets/plugins/chosen/chosen.jquery.min.js"></script>
<script src="~/Assets/js/pages/form-elements.js"></script>
<style>
    .btn-default {
        color: #333;
        background-color: #FFF;
        border-color: #CCC;
        height: 34px;
    }
</style>



<div class="page-header">
    <div class="pull-left">
        <ol class="breadcrumb visible-sm visible-md visible-lg">
            <li><a href="@Url.Action("Index","Home",new{area=""})"><i class="icon fa fa-home"></i>主页</a></li>
            <li><a href="~/PerationAndMaintenanceArea/Maintenance/Maintenance"><i class="fa fa-envelope"></i>运维项目管理</a></li>
            <li><a href="@Url.Action("Particulars","Maintenance",new{area="PerationAndMaintenanceArea",projectId=ViewBag.ID})"><i class="fa fa-envelope"></i>运维工作详情</a></li>
            <li class="active"><a href="#"><i class="fa fa-envelope"></i>运维记录</a></li>
        </ol>
    </div>
</div>



 
@{
    if (ViewBag.Flag == "True")
    {
    <div class="alert alert-success">
        <button type="button" class="close" data-dismiss="alert">×</button>
        <strong>&emsp;@ViewBag.FlagInfo！</strong>
    </div>
    }
    if (ViewBag.Flag == "False")
    {
    <div class="alert alert-danger">
        <button type="button" class="close" data-dismiss="alert">×</button>
        <strong>&emsp;操作失败！</strong> @ViewBag.FlagInfo
    </div>
    }
}




<div class="row">
    <div class="col-lg-12">
        <div class="panel">
            <div class="panel-heading bk-bg-primary">
                <h6><i class="fa fa-table red"></i><span style="font-size: medium" class="break">@ViewBag.RecordName 运维项目的记录</span></h6>
                @if (ViewBag.IsAdmin == true || ViewBag.FZ == true)
                {
                    <div class="panel-actions">
                    <a data-toggle="modal" data-target="#TaskBookCreateModal" class="bk-margin-5 btn btn-default  btn-sm" style="background-color: #ECEDF0">&nbsp;&nbsp;增加记录&nbsp;&nbsp;</a>
                </div>  
                }
            </div>
            <div class="panel-body">
                <div class="table-responsive">
                    <table class="table table-hover">
                        <thead>
                            <tr>
                                <th style="text-align: center">记录人</th>
                                <th style="text-align: center">记录操作类型</th>
                                <th style="text-align: center">记录时间</th>
                                <th style="text-align: center">操作时间</th>
                                <th style="text-align: center">文档附件</th>
                                <th style="text-align: center">运维记录相关操作</th>
                            </tr>
                        </thead>
                        <tbody id="cwl">
                            @if (ViewBag.Record != null)
                            {
                                foreach (ProjectManintenanceRecordViewModel item in ViewBag.Record)
                                {
                                <tr>
                                    <td style="text-align: center;color:black">@item.record_name</td>
                                    <td style="text-align: center;color:black">@item.record_operationtype</td>
                                    <td style="text-align: center;color:black">@item.record_time.ToString("yyyy-MM-dd")</td>
                                    <td style="text-align: center;color:black">@item.record_operation_time.ToString("yyyy-MM-dd")</td>


                                    <td style="text-align: center">
                                        <a data-target="#BugInfoModal" onclick="ShowTaskBookInfoModal('@item.record_id')" data-toggle="modal" style="color:green">@item.record_accessory</a>
                                    </td>
                                    <td style="text-align: center">
                                        <a onclick="neirong('@item.record_id')" data-toggle="modal" data-target="#NeiRong" style="color:blue">&nbsp;&nbsp;内容&nbsp;&nbsp;</a>
                                        @if (ViewBag.IsAdmin == true || ViewBag.FZ == true)
                                        {
                                        <a onclick="getid('@item.record_id')" data-toggle="modal" data-target="#Compile"  style="color:blue">&nbsp;&nbsp;编辑&nbsp;&nbsp;</a>
                                        <a onclick="deleteid('@item.record_id')" data-toggle="modal" data-target="#Delete" style="color:red">&nbsp;&nbsp;删除&nbsp;&nbsp;</a>
                                        }
                                    </td>
                                </tr>
                                }
                            }
                        </tbody>
                    </table>
                </div>
            </div>
        </div>
    </div>
</div>


<script>
    function getid(bugId) {

        $.ajax({
            type: "POST",
            //url: "/KSManager/PerationAndMaintenanceArea/Maintenance/reacordUpdat",
            url:'@Url.Action("reacordUpdat","Maintenance",new{area="PerationAndMaintenanceArea"})',
            data: "roleId=" + bugId,
            error: function () { alert("服务器出错！"); },
            success: function (data) {
                $("#t_record_name").val(data["record_name"]);
                $("#t_record_operationtype").val(data["record_operationtype"]);
                $("#t_record_content").val(data["record_content"]);
                $("#hid_appops_id").val(data["record_id"]);
                $("#selcet_text_DTime_idd").val(data["record_operation_time_selcet"]);
            }
        });
    }

</script>

<script>
    function deleteid(bugId) {

        $.ajax({
            type: "POST",
            //url: "/KSManager/PerationAndMaintenanceArea/Maintenance/reacordUpdat",
            url:'@Url.Action("reacordUpdat","Maintenance",new{area="PerationAndMaintenanceArea"})',
            data: "roleId=" + bugId,
            error: function () { alert("服务器出错！"); },
            success: function (data) {
                $("#delete_appops_id").val(data["record_id"]);
            }
        });
    }

</script>



<!-- 下载附件 模态框（Modal） -->
<script>
    function ShowTaskBookInfoModal(bugId) {
        $.ajax({
            type: "POST",
            //url: "/KSManager/PerationAndMaintenanceArea/Maintenance/GetDocument",
            url:'@Url.Action("GetDocument","Maintenance",new{arer="PerationAndMaintenanceArea"})',
            data: "bugId=" + bugId,
            error: function () { alert("服务器出错！"); },
            success: function (data) {

                if (data["BugFileSaveName"] == "") {

                    $("#a_DownloadBugFile").text("");
                }
                else {
            
                    $("#a_DownloadBugFile").text(data["BugFileShowName"]);
                    $("#a_DownloadBugFile").attr("href", '@Url.Content("~/Home/DownLoadFile?filePath=")' + data["BugFileSaveName"] + "&type=Document&fileName=" + data["BugFileSaveName"]);
                }
            }
        });
    }
</script>





@*记录校验*@
 <script>
     $(document).ready(function () {
         $("#reacord_id").validate({
             rules: {
                 tb_record_name: { required: true,maxlength:6},
                 tb_record_content: { required: true },
             },
             messages: {
                 tb_record_name: { required: "记录人姓名不能为空",maxlength:"名字长度不能超过6个字" },
                 tb_record_content: { required: "内容不能为空" },
             },
             errorPlacement: function (error, element) {
                 error.appendTo(element.next("span.t_record_name"));
                 error.appendTo(element.next("span.t_record_content"));
             }
         });
         $("span.t_record_name").css("color", "red");
         $("span.t_record_content").css("color", "red");
     })




     $("#selcet_DTime").datepicker({
         autoclose: true,
         pickerPosition: "bottom-right"
     });
     $("#selcet_Time").datepicker({
         autoclose: true,
         pickerPosition: "bottom-right"
     });
    </script>

<style>
      #table_CreateProject td {
       padding-left: 5px;
       padding-top: 5px
   }
      #table_CreateProjectt td {
       padding-left: 5px;
       padding-top: 5px
   }
</style>
<!-- 增加记录 模态框（Modal） -->

<div class="modal fade" id="TaskBookCreateModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">

    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">
                    &times;
                </button>
                <h4 class="modal-title" id="myModalLabel">新增记录</h4>
            </div>
            <form id="reacord_id" enctype="multipart/form-data" action="@Url.Action("Reacord_Insert", "Maintenance", new { area = "PerationAndMaintenanceArea" })" method="POST" >

                <div class="modal-body">
                      <input type="hidden" name="hid_ProjectId" />
                    <table id="table_CreateProject">
                        <tr>
                              <td>运维操作类型：</td>
                              <td><select name="select_record_operationtype" class="form-control selectpicker">
                                <option value="上线">上线</option>
                                <option value="变更">变更</option>
                                <option value="故障">故障</option>
                                <option value="下线">下线</option>
                                <option value="其他">其他</option>
                            </select>
                            <input type="hidden" name="hid_appops_id" value="@ViewBag.ID"/>
                            <input type="hidden" name="hid_appops_name_id" value="@ViewBag.NAMEID"/>
                              </td>
                              <td>操作日期：</td>
                              <td style="vertical-align:middle" >
                              <div  class="input-append date"  style="display:inline-block; height:20px"  id="selcet_DTime"  data-date="@DateTime.Now.ToString("yyyy-MM-dd")" data-date-format="yyyy-mm-dd">
                                <input  id="selcet_text_DTime_id"  name="selcet_text_DTime" size="10" type="text"  value="@DateTime.Now.ToString("yyyy-MM-dd")">
                             <span class="add-on"><i class="icon-th"></i></span>
                             </div>
                              </td>
                        </tr>
                        <tr>
                              <td>内容：</td>
                              <td  colspan="5">
                                  <textarea name="tb_record_content" class="form-control" rows="5"></textarea>
                            <span class="t_record_content"></span>
                              </td>
                        </tr>
                        <tr>
                             <td>附件：</td>
                             <td  colspan="5">
                             <input name="tb_record_accessory" style="border-color: cornflowerblue" placeholder="Text" type="file">
                             </td>
                        </tr>
                    </table>
                 
                    
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-default" data-dismiss="modal">
                        关闭
                    </button>
                    <input type="submit" value="新增" class="btn btn-primary" />
                </div>

            </form>
        </div>
        <!-- /.modal-content -->
    </div>
    <!-- /.modal -->
</div>

<!-- 编辑记录 模态框（Modal） -->
<div class="modal fade" id="Compile" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">

    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">
                    &times;
                </button>
                <h4 class="modal-title" id="myModalLabell">编辑记录</h4>
            </div>
            <form enctype="multipart/form-data" action="@Url.Action("Reacord_updat", "Maintenance", new { area = "PerationAndMaintenanceArea" })" method="POST" >

                <div class="modal-body">

                    <input type="hidden" name="hid_ProjectId" />

                            <table id="table_CreateProjectt">
                        <tr>
                              <td>运维操作类型：</td>
                              <td><select name="select_record_operationtype" class="form-control selectpicker">
                                <option value="上线">上线</option>
                                <option value="变更">变更</option>
                                <option value="故障">故障</option>
                                <option value="下线">下线</option>
                                <option value="其他">其他</option>
                            </select>
                               <input type="hidden" id="hid_appops_id" name="td_appops_id" value="" />
                              </td>
                              <td>操作日期：</td>
                              <td style="vertical-align:middle" >
                              <div  class="input-append date"  style="display:inline-block; height:20px"  id="selcet_Time"  data-date="@DateTime.Now.ToString("yyyy-MM-dd")" data-date-format="yyyy-mm-dd">
                                <input  id="selcet_text_DTime_idd"  name="selcet_text_DTime" size="10" type="text"  value="@DateTime.Now.ToString("yyyy-MM-dd")">
                             <span class="add-on"><i class="icon-th"></i></span>
                             </div>
                              </td>
                        </tr>
                        <tr>
                              <td>内容：</td>
                              <td  colspan="5">
                                  <textarea name="tb_record_content" class="form-control" id="t_record_content" rows="5"></textarea>
                            <span class="t_record_content"></span>
                              </td>
                        </tr>
                        <tr>
                             <td>附件：</td>
                             <td  colspan="5">
                             <input name="tb_record_accessory" style="border-color: cornflowerblue" placeholder="Text" type="file">
                             </td>
                        </tr>
                    </table>

                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-default" data-dismiss="modal">
                        关闭
                    </button>
                    <input type="submit" value="修改" class="btn btn-primary" />
                </div>

            </form>
        </div>
        <!-- /.modal-content -->
    </div>
    <!-- /.modal -->
</div>

<!-- 删除记录 模态框（Modal） -->
<div class="modal fade" id="Delete" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">

    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">
                    &times;
                </button>
            </div>
            <form enctype="multipart/form-data" action="@Url.Action("Reacord_Delete", "Maintenance", new { area = "PerationAndMaintenanceArea" })" method="POST" >

                <div class="modal-body">
                    <input type="hidden" name="hid_ProjectId" />
                    <div class="row">
                        <label class="col-md-3 control-label" for="text-input">确定删除此项记录么</label>
                        <input type="hidden" id="delete_appops_id" name="delete_appops_idd" value="" />
                    </div>
                    <br />
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-default" data-dismiss="modal">
                        关闭
                    </button>
                    <input type="submit" value="确定" class="btn btn-primary" />
                </div>

            </form>
        </div>
        <!-- /.modal-content -->
    </div>
    <!-- /.modal -->
</div>


<!-- 记录附件 模态框（Modal） -->
<div class="modal fade" id="BugInfoModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">
                    &times;
                </button>
                <h4 class="modal-title" id="myModalLabel">运维记录附件</h4>
            </div>
            <div class="modal-body" style="font-size: small">

                <div class="row">
                    <label class="col-md-3 control-label" for="text-input">点击下载：</label>
                    <div class="col-md-9">
                        <a id="a_DownloadBugFile">
                            @*<label id="lb_BugFile" style="width: 100%" class="col-md-8 control-label" for="text-input"></label>*@
                        </a>
                    </div>
                </div>

            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">
                    关闭
                </button>
            </div>
        </div>
        <!-- /.modal-content -->
    </div>
    <!-- /.modal -->
</div>









<script>
    function neirong(bugId) {

        $.ajax({
            type: "POST",
            //url: "/KSManager/PerationAndMaintenanceArea/Maintenance/reacordUpdat",
            url:'@Url.Action("reacordUpdat","Maintenance",new{area="PerationAndMaintenanceArea"})',
            data: "roleId=" + bugId,
            error: function () { alert("服务器出错！"); },
            success: function (data) {
                $("#nr_record_content").text(data["record_content"]);
            }
        });
    }

</script>

<!-- 记录内容 模态框（Modal） -->
<div class="modal fade" id="NeiRong" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">

    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">
                    &times;
                </button>
                <h4 class="modal-title" id="myModalLabell">记录内容</h4>
            </div>
            <form enctype="multipart/form-data" action="@Url.Action("Reacord_updat", "Maintenance", new { area = "PerationAndMaintenanceArea" })" method="POST" >

                <div class="modal-body">
                    <input type="hidden" name="hid_ProjectId" />
                 
                    <br />

                    <div class="row">
                        <div >
                            <label id="nr_record_content" style="width: 100%" class="col-md-8 control-label" for="text-input"></label>
                        </div>
                    </div>
                    <br />

                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-default" data-dismiss="modal">
                        关闭
                    </button>
                </div>

            </form>
        </div>
        <!-- /.modal-content -->
    </div>
    <!-- /.modal -->
</div>